package app;

import edu.tum.cs.i1.pse.BubbleSort;
import edu.tum.cs.i1.pse.MergeSort;
import edu.tum.cs.i1.pse.QuickSort;
import edu.tum.cs.i1.pse.SortStrategy;

public class Policy {
	
	public Policy(ArraySorter arraySorter){
		this.arraySorter = arraySorter;
	}
		
	private ArraySorter arraySorter;
	
	private boolean timeIsImportant = true;
	
	private boolean spaceIsImportant = true;
	
	public void configure(boolean _timeIsImportant, boolean _spaceIsImportant){
		this.timeIsImportant = _timeIsImportant;
		this.spaceIsImportant = _spaceIsImportant;		
		SortStrategy sortStrategy;
		
		if ( this.spaceIsImportant && this.timeIsImportant){
			sortStrategy = new MergeSort();
		}else if( this.timeIsImportant){
			sortStrategy = new QuickSort();
		} else {
			sortStrategy = new BubbleSort();
		}
		
		arraySorter.setSortStrategy(sortStrategy);
	}

}
